home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
doom
/
quake2.zip
/
TF1_2SRC.ZIP
/
QUAKE
/
FORTRESS
/
SOURCE
/
WEAPONS.QC
< prev
next >
Wrap
Text File
|
1996-09-10
|
47KB
|
2,041 lines
/*
Heavily Modified for TeamFortress V1.2
Robin Walker, John Cook
*/
void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
void (entity targ, entity inflictor, entity attacker, float damage, float T_flags) TF_T_Damage;
void () player_run;
void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
void(vector org, vector vel, float damage) SpawnBlood;
void() SuperDamageSound;
// TeamFortress Impulse Commands
void() TeamFortress_ChangeClass;
void() TeamFortress_Inventory;
void() TeamFortress_ShowTF;
void() TeamFortress_SniperWeapon;
void() TeamFortress_AssaultWeapon;
void() TeamFortress_PrimeGrenade;
void() TeamFortress_ThrowGrenade;
void() TeamFortress_DetonatePipebombs;
void() PipebombTouch;
// TeamFortress Pre-Impulse Commands
void(float scanrange) TeamFortress_Scan;
void(float timer) TeamFortress_SetDetpack;
void(float helpindex) TeamFortress_Help;
void(float tflag) TeamFortress_Toggle;
void(float skinno) TeamFortress_Multiskin;
void(float funcno) TeamFortress_Team;
// Multiskin Functions
void() Multiskin_NextSkin;
void() Multiskin_PrevSkin;
// BioInfection functions
void() BioInfection_Decay;
void() BioInfection_MonsterDecay;
void() player_touch;
// PC_UNDEFINED viewing functions
void() TF_MovePlayer;
// called by worldspawn
void() W_Precache =
{
precache_sound ("weapons/r_exp3.wav"); // new rocket explosion
precache_sound ("weapons/rocket1i.wav");// spike gun
precache_sound ("weapons/sgun1.wav");
precache_sound ("weapons/guncock.wav"); // player shotgun
precache_sound ("weapons/ric1.wav"); // ricochet (used in c code)
precache_sound ("weapons/ric2.wav"); // ricochet (used in c code)
precache_sound ("weapons/ric3.wav"); // ricochet (used in c code)
precache_sound ("weapons/spike2.wav"); // super spikes
precache_sound ("weapons/tink1.wav"); // spikes tink (used in c code)
precache_sound ("weapons/grenade.wav"); // grenade launcher
precache_sound ("weapons/bounce.wav"); // grenade bounce
precache_sound ("weapons/shotgn2.wav"); // super shotgun
if (!(IS_NET_SERVER))
precache_sound ("weapons/sniper.wav"); // sniper rifle
};
float() crandom =
{
return 2*(random() - 0.5);
};
/*
================
W_FireAxe
================
*/
void() W_FireAxe =
{
local vector source;
local vector org;
source = self.origin + '0 0 16';
traceline (source, source + v_forward*64, FALSE, self);
if (trace_fraction == 1.0)
return;
org = trace_endpos - v_forward*4;
if (trace_ent.takedamage)
{
trace_ent.axhitme = 1;
SpawnBlood (org, '0 0 0', 20);
TF_T_Damage (trace_ent, self, self, 20, TF_TD_NOTTEAM);
}
else
{ // hit wall
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
}
};
/*
================
W_FireMedikit
================
*/
void() W_FireMedikit =
{
local vector source;
local vector org;
local float healam;
source = self.origin + '0 0 16';
traceline (source, source + v_forward*64, FALSE, self);
if (trace_fraction == 1.0)
return;
org = trace_endpos - v_forward*4;
if (trace_ent.takedamage)
{
if (trace_ent.classname == "player")
{
if ((trace_ent.team == self.team) || (coop))
{
healam = NIT_MEDIKIT_HEAL;
if (self.ammo_medikit < healam)
healam = self.ammo_medikit;
// check if the healed player is infected
if (trace_ent.tfstate & TFSTATE_INFECTED)
{
healam = rint(trace_ent.health / 2);
// remove the infection
trace_ent.tfstate = trace_ent.tfstate - (trace_ent.tfstate & TFSTATE_INFECTED);
// some damage is caused (because of the use of leeches!)
// remove half their remaining health
T_Damage(trace_ent, self, self, healam);
SpawnBlood(org, '0 0 0', 30);
sprint(trace_ent, "Your infection is cured!\n");
sprint(self, "You have healed ");
sprint(self, trace_ent.netname);
sprint(self, " of the infection.\n");
return;
}
if (healam > 0 && trace_ent.health < trace_ent.max_health)
{
sound(trace_ent, CHAN_WEAPON, "items/r_item1.wav", 1, ATTN_NORM);
self.ammo_medikit = self.ammo_medikit - healam;
trace_ent.axhitme = 1;
SpawnBlood (org, '0 0 0', 20);
T_Heal(trace_ent, healam, 0);
}
}
}
}
else
{ // hit wall
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
}
};
/*
================
W_FireBioweapon
================
*/
void() W_FireBioweapon =
{
local vector source;
local vector org;
local float healam;
local entity BioInfection;
source = self.origin + '0 0 16';
traceline (source, source + v_forward*64, FALSE, self);
if (trace_fraction == 1.0)
return;
org = trace_endpos - v_forward*4;
if (trace_ent.takedamage)
{
if (trace_ent.classname == "player")
{
trace_ent.axhitme = 1;
SpawnBlood (org, '0 0 0', 20);
T_Damage (trace_ent, self, self, 10);
if (trace_ent.playerclass == PC_MEDIC)
return;
trace_ent.tfstate = trace_ent.tfstate | TFSTATE_INFECTED;
BioInfection = spawn ();
BioInfection.classname = "timer";
BioInfection.owner = trace_ent;
BioInfection.nextthink = time + 2;
BioInfection.think = BioInfection_Decay;
BioInfection.enemy = self;
BioInfection.tfstate = TFSTATE_ALTKILL;
BioInfection.altkillweapon = AK_BIOWEAPON;
trace_ent.touch = player_touch;
}
else if (trace_ent.flags == FL_MONSTER)
{
if (trace_ent.classname == "monster_zombie")
{
// zombie slayer!
T_Damage (trace_ent, self, self, 200);
}
trace_ent.axhitme = 1;
SpawnBlood(org, '0 0 0', 20);
T_Damage (trace_ent, self, self, 10);
BioInfection = spawn ();
BioInfection.classname = "timer";
BioInfection.nextthink = time + 2;
BioInfection.think = BioInfection_MonsterDecay;
BioInfection.owner = self;
BioInfection.enemy = trace_ent;
}
else // must be a switch
{
trace_ent.axhitme = 1;
SpawnBlood (org, '0 0 0', 30);
T_Damage(trace_ent, self, self, 40);
}
}
else
{ // hit wall
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
}
};
//============================================================================
vector() wall_velocity =
{
local vector vel;
vel = normalize (self.velocity);
vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
vel = vel + 2*trace_plane_normal;
vel = vel * 200;
return vel;
};
/*
================
SpawnMeatSpray
================
*/
void(vector org, vector vel) SpawnMeatSpray =
{
local entity missile, mpuff;
local vector org;
missile = spawn ();
missile.owner = self;
missile.movetype = MOVETYPE_BOUNCE;
missile.solid = SOLID_NOT;
makevectors (self.angles);
missile.velocity = vel;
missile.velocity_z = missile.velocity_z + 250 + 50*random();
missile.avelocity = '3000 1000 2000';
// set missile duration
missile.nextthink = time + 1;
missile.think = SUB_Remove;
setmodel (missile, "progs/zom_gib.mdl");
setsize (missile, '0 0 0', '0 0 0');
setorigin (missile, org);
};
/*
================
SpawnBlood
================
*/
void(vector org, vector vel, float damage) SpawnBlood =
{
particle (org, vel*0.1, 73, damage*2);
};
/*
================
spawn_touchblood
================
*/
void(float damage) spawn_touchblood =
{
local vector vel;
vel = wall_velocity () * 0.2;
SpawnBlood (self.origin + vel*0.01, vel, damage);
};
/*
================
SpawnChunk
================
*/
void(vector org, vector vel) SpawnChunk =
{
particle (org, vel*0.02, 0, 10);
};
/*
==============================================================================
MULTI-DAMAGE
Collects multiple small damages into a single damage
==============================================================================
*/
entity multi_ent;
float multi_damage;
void() ClearMultiDamage =
{
multi_ent = world;
multi_damage = 0;
};
void() ApplyMultiDamage =
{
if (!multi_ent)
return;
TF_T_Damage (multi_ent, self, self, multi_damage, TF_TD_NOTTEAM);
};
void(entity hit, float damage) AddMultiDamage =
{
if (!hit)
return;
if (hit != multi_ent)
{
ApplyMultiDamage ();
multi_damage = damage;
multi_ent = hit;
}
else
multi_damage = multi_damage + damage;
};
/*
==============================================================================
BULLETS
==============================================================================
*/
/*
================
TraceAttack
================
*/
void(float damage, vector dir) TraceAttack =
{
local vector vel, org;
vel = normalize(dir + v_up*crandom() + v_right*crandom());
vel = vel + 2*trace_plane_normal;
vel = vel * 200;
org = trace_endpos - dir*4;
if (trace_ent.takedamage)
{
SpawnBlood (org, vel*0.2, damage);
AddMultiDamage (trace_ent, damage);
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
}
};
/*
================
FireBullets
Used by shotgun, super shotgun, assault cannon, and enemy soldier firing
Go to the trouble of combining multiple pellets into a single damage call.
================
*/
void(float shotcount, vector dir, vector spread) FireBullets =
{
local vector direction;
local vector src;
makevectors(self.v_angle);
src = self.origin + v_forward*10;
src_z = self.absmin_z + self.size_z * 0.7;
ClearMultiDamage ();
while (shotcount > 0)
{
direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
traceline (src, src + direction*2048, FALSE, self);
if (trace_fraction != 1.0)
TraceAttack (4, direction);
shotcount = shotcount - 1;
}
ApplyMultiDamage ();
};
/*
================
W_FireShotgun
================
*/
void() W_FireShotgun =
{
local vector dir;
sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
self.currentammo = self.ammo_shells = self.ammo_shells - 1;
dir = aim (self, 100000);
FireBullets (6, dir, '0.04 0.04 0');
};
/*
================
W_FireSuperShotgun
================
*/
void() W_FireSuperShotgun =
{
local vector dir;
if (self.currentammo == 1)
{
W_FireShotgun ();
return;
}
sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
self.punchangle_x = -4;
self.currentammo = self.ammo_shells = self.ammo_shells - 2;
dir = aim (self, 100000);
FireBullets (14, dir, '0.14 0.08 0');
};
/*
================
FireSniperBullet
Used by sniper rifle firing (W_FireSniperRifle)
================
*/
void(vector direction, float damage) FireSniperBullet =
{
local vector src;
makevectors(self.v_angle);
src = self.origin + v_forward*10;
src_z = self.absmin_z + self.size_z * 0.7;
ClearMultiDamage ();
traceline (src, src + direction*2048, FALSE, self);
if (trace_fraction != 1.0)
TraceAttack (damage, direction);
ApplyMultiDamage ();
};
/*
=================================
TeamFortress : W_FireSniperRifle
=================================
*/
void() W_FireSniperRifle =
{
local vector dir;
if (IS_NET_SERVER)
sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
else
sound (self ,CHAN_WEAPON, "weapons/sniper.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
self.currentammo = self.ammo_shells = self.ammo_shells - 1;
dir = aim (self, 100000);
FireSniperBullet (dir,200);
};
/*
===================================
TeamFortress : W_FireAutoRifle
===================================
*/
void() W_FireAutoRifle =
{
local vector dir;
if (IS_NET_SERVER)
sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
else
sound (self ,CHAN_WEAPON, "weapons/sniper.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
self.currentammo = self.ammo_shells = self.ammo_shells - 1;
dir = aim (self, 100000);
FireSniperBullet (dir,4);
};
/*
================
TeamFortress : W_FireAssaultCannon
================
*/
void() W_FireAssaultCannon =
{
local vector dir;
// Get a minigun sound effect
sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
self.punchangle_x = -4;
self.currentammo = self.ammo_shells = self.ammo_shells - 1;
dir = aim (self, 100000);
FireBullets (5, dir, '0.04 0.04 0');
};
/*
==============================================================================
ROCKETS
==============================================================================
*/
void() s_explode1 = [0, s_explode2] {};
void() s_explode2 = [1, s_explode3] {};
void() s_explode3 = [2, s_explode4] {};
void() s_explode4 = [3, s_explode5] {};
void() s_explode5 = [4, s_explode6] {};
void() s_explode6 = [5, SUB_Remove] {};
void() BecomeExplosion =
{
self.movetype = MOVETYPE_NONE;
self.velocity = '0 0 0';
self.touch = SUB_Null;
setmodel (self, "progs/s_explod.spr");
self.solid = SOLID_NOT;
s_explode1 ();
};
void() T_MissileTouch =
{
local float damg;
if (other == self.owner)
return; // don't explode on owner
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
damg = 100 + random()*20;
if (other.health)
{
if (other.classname == "monster_shambler")
damg = damg * 0.5; // mostly immune
T_Damage (other, self, self.owner, damg );
}
// don't do radius damage to the other, because all the damage
// was done in the impact
T_RadiusDamage (self, self.owner, 120, other);
// sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
self.origin = self.origin - 8*normalize(self.velocity);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
BecomeExplosion ();
};
/*
================
W_FireRocket
================
*/
void() W_FireRocket =
{
local entity missile, mpuff;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
missile = spawn ();
missile.owner = self;
missile.movetype = MOVETYPE_FLYMISSILE;
missile.solid = SOLID_BBOX;
// set missile speed
makevectors (self.v_angle);
missile.velocity = aim(self, 1000);
missile.velocity = missile.velocity * 1000;
missile.angles = vectoangles(missile.velocity);
missile.touch = T_MissileTouch;
// Set ALTKILL
missile.tfstate = missile.tfstate | TFSTATE_ALTKILL;
missile.altkillweapon = AK_MISSILE;
// set missile duration
missile.nextthink = time + 5;
missile.think = SUB_Remove;
setmodel (missile, "progs/missile.mdl");
setsize (missile, '0 0 0', '0 0 0');
setorigin (missile, self.origin + v_forward*8 + '0 0 16');
};
/*
===============================================================================
LIGHTNING
===============================================================================
*/
/*
=================
LightningDamage
=================
*/
void(vector p1, vector p2, entity from, float damage) LightningDamage =
{
local entity e1, e2;
local vector f;
f = p2 - p1;
normalize (f);
f_x = 0 - f_y;
f_y = f_x;
f_z = 0;
f = f*16;
e1 = e2 = world;
traceline (p1, p2, FALSE, self);
if (trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage*4);
TF_T_Damage (trace_ent, from, from, damage, TF_TD_NOTTEAM);
if (self.classname == "player")
{
if (other.classname == "player")
trace_ent.velocity_z = trace_ent.velocity_z + 400;
}
}
e1 = trace_ent;
traceline (p1 + f, p2 + f, FALSE, self);
if (trace_ent != e1 && trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage*4);
TF_T_Damage (trace_ent, from, from, damage, TF_TD_NOTTEAM);
}
e2 = trace_ent;
traceline (p1 - f, p2 - f, FALSE, self);
if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage*4);
TF_T_Damage (trace_ent, from, from, damage, TF_TD_NOTTEAM);
}
};
void() W_FireLightning =
{
local vector org;
if (self.ammo_cells < 1)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
// explode if under water
if (self.waterlevel > 1)
{
T_RadiusDamage (self, self, 35*self.ammo_cells, world);
self.ammo_cells = 0;
W_SetCurrentAmmo ();
return;
}
if (self.t_width < time)
{
sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
self.t_width = time + 0.6;
}
self.punchangle_x = -2;
self.currentammo = self.ammo_cells = self.ammo_cells - 1;
org = self.origin + '0 0 16';
traceline (org, org + v_forward*600, TRUE, self);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
WriteEntity (MSG_BROADCAST, self);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
WriteCoord (MSG_BROADCAST, trace_endpos_x);
WriteCoord (MSG_BROADCAST, trace_endpos_y);
WriteCoord (MSG_BROADCAST, trace_endpos_z);
LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
};
//=============================================================================
void() GrenadeExplode =
{
T_RadiusDamage (self, self.owner, 120, world);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
BecomeExplosion ();
};
void() GrenadeTouch =
{
if (other == self.owner)
return; // don't explode on owner
if (other.takedamage == DAMAGE_AIM)
{
GrenadeExplode();
return;
}
sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
if (self.velocity == '0 0 0')
self.avelocity = '0 0 0';
};
/*
================
W_FireGrenade
================
*/
void() W_FireGrenade =
{
local entity missile, mpuff;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
missile = spawn ();
missile.owner = self;
missile.movetype = MOVETYPE_BOUNCE;
missile.solid = SOLID_BBOX;
// Set grenade type based on firing mode
if (self.weaponmode == GL_NORMAL)
{
missile.classname = "grenade";
missile.touch = GrenadeTouch;
missile.nextthink = time + 2.5;
}
if (self.weaponmode == GL_PIPEBOMB)
{
missile.classname = "pipebomb";
missile.touch = PipebombTouch;
missile.nextthink = time + (60 * 3); // Remove pipebombs older than 3 minutes
}
// set missile speed
makevectors (self.v_angle);
if (self.v_angle_x)
missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
else
{
missile.velocity = aim(self, 10000);
missile.velocity = missile.velocity * 600;
missile.velocity_z = 200;
}
missile.avelocity = '300 300 300';
missile.angles = vectoangles(missile.velocity);
// Set ALTKILL
missile.tfstate = missile.tfstate | TFSTATE_ALTKILL;
missile.altkillweapon = AK_MISSILE;
missile.think = GrenadeExplode;
setmodel (missile, "progs/grenade.mdl");
setsize (missile, '0 0 0', '0 0 0');
setorigin (missile, self.origin);
};
//=============================================================================
void() spike_touch;
void() superspike_touch;
/*
===============
launch_spike
Used for both the player and the ogre
===============
*/
void(vector org, vector dir, float Ak, float AkW) launch_spike =
{
newmis = spawn ();
newmis.owner = self;
newmis.movetype = MOVETYPE_FLYMISSILE;
newmis.solid = SOLID_BBOX;
newmis.angles = vectoangles(dir);
// Alternative weapon
if (Ak)
{
newmis.tfstate = newmis.tfstate | TFSTATE_ALTKILL;
newmis.altkillweapon = AkW;
}
newmis.touch = spike_touch;
newmis.classname = "spike";
newmis.think = SUB_Remove;
newmis.nextthink = time + 6;
setmodel (newmis, "progs/spike.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newmis, org);
newmis.velocity = dir * 1000;
};
void() W_FireSuperSpikes =
{
local vector dir;
local entity old;
sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 2;
dir = aim (self, 1000);
launch_spike (self.origin + '0 0 16', dir,0 ,0);
newmis.touch = superspike_touch;
setmodel (newmis, "progs/s_spike.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
self.punchangle_x = -2;
};
void(float ox) W_FireSpikes =
{
local vector dir;
local entity old;
makevectors (self.v_angle);
if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
{
W_FireSuperSpikes ();
return;
}
if (self.ammo_nails < 1)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 1;
dir = aim (self, 1000);
launch_spike (self.origin + '0 0 16' + v_right*ox, dir, 0, 0);
self.punchangle_x = -2;
};
.float hit_z;
void() spike_touch =
{
local float rand;
if (other == self.owner)
return;
if (other.solid == SOLID_TRIGGER)
return; // trigger field, do nothing
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
// hit something that bleeds
if (other.takedamage)
{
spawn_touchblood (9);
TF_T_Damage (other, self, self.owner, 9, TF_TD_NOTTEAM);
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
if (self.classname == "wizspike")
WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
else if (self.classname == "knightspike")
WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
else
WriteByte (MSG_BROADCAST, TE_SPIKE);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
}
remove(self);
};
void() superspike_touch =
{
local float rand;
if (other == self.owner)
return;
if (other.solid == SOLID_TRIGGER)
return; // trigger field, do nothing
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
// hit something that bleeds
if (other.takedamage)
{
spawn_touchblood (18);
TF_T_Damage (other, self, self.owner, 18, TF_TD_NOTTEAM);
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
}
remove(self);
};
/*
===============================================================================
PLAYER WEAPON USE
===============================================================================
*/
void() W_SetCurrentAmmo =
{
player_run (); // get out of any weapon firing states
self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
if (self.weapon == IT_AXE)
{
self.currentammo = 0;
self.weaponmodel = "progs/v_axe.mdl";
self.weaponframe = 0;
}
else if (self.weapon == IT_SHOTGUN)
{
self.currentammo = self.ammo_shells;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_shot.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_SHELLS;
}
else if (self.weapon == IT_SUPER_SHOTGUN)
{
self.currentammo = self.ammo_shells;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_shot2.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_SHELLS;
}
else if (self.weapon == IT_NAILGUN)
{
self.currentammo = self.ammo_nails;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_nail.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_NAILS;
}
else if (self.weapon == IT_SUPER_NAILGUN)
{
self.currentammo = self.ammo_nails;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_nail2.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_NAILS;
}
else if (self.weapon == IT_GRENADE_LAUNCHER)
{
self.currentammo = self.ammo_rockets;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_rock.mdl";
self.weaponframe = 0;
}
if (self.weaponmode == GL_NORMAL)
sprint(self, "Normal grenade mode\n");
if (self.weaponmode == GL_PIPEBOMB)
sprint(self, "Pipebomb mode\n");
self.items = self.items | IT_ROCKETS;
}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{
self.currentammo = self.ammo_rockets;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_rock2.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_ROCKETS;
}
else if (self.weapon == IT_LIGHTNING)
{
self.currentammo = self.ammo_cells;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_light.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_CELLS;
}
else if (self.weapon == IT_EXTRA_WEAPON)
{
if (self.secondary_weapon == NIT_SNIPER_RIFLE)
{
self.currentammo = self.ammo_shells;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_shot.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_SHELLS;
sprint(self,"Sniper rifle ready\n");
}
else if (self.secondary_weapon == NIT_AUTO_RIFLE)
{
self.currentammo = self.ammo_shells;
if (!(self.tfstate & TFSTATE_RELOADING))
{
self.weaponmodel = "progs/v_shot.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_SHELLS;
sprint(self,"Rifle on fully auto\n");
}
else if (self.secondary_weapon == NIT_ASSAULT_CANNON)
{
self.currentammo = self.ammo_shells;
if ((!(self.tfstate & TFSTATE_RELOADING)) && (self.heat == 0))
{
self.weaponmodel = "progs/v_nail2.mdl";
self.weaponframe = 0;
}
self.items = self.items | IT_SHELLS;
}
else if (self.secondary_weapon == NIT_MEDIKIT)
{
self.currentammo = 0;
self.weaponmodel = "progs/v_axe.mdl";
self.weaponframe = 0;
sprint(self, "Medikit readied\n");
}
else if (self.secondary_weapon == NIT_BIOWEAPON)
{
self.currentammo = 0;
self.weaponmodel = "progs/v_axe.mdl";
self.weaponframe = 0;
sprint(self, "BioWeapon readied\n");
}
}
else
{
self.currentammo = 0;
self.weaponmodel = "";
self.weaponframe = 0;
}
};
float() W_BestWeapon =
{
local float it;
it = self.items;
if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
return IT_LIGHTNING;
else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
return IT_SUPER_NAILGUN;
else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
return IT_SUPER_SHOTGUN;
else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
return IT_NAILGUN;
else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
return IT_SHOTGUN;
/*
if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
return IT_ROCKET_LAUNCHER;
else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
return IT_GRENADE_LAUNCHER;
*/
if (self.playerclass == PC_MEDIC)
{
self.secondary_weapon = NIT_BIOWEAPON;
return IT_EXTRA_WEAPON;
}
return IT_AXE;
};
float() W_CheckNoAmmo =
{
if (self.currentammo > 0)
return TRUE;
if (self.weapon == IT_AXE)
return TRUE;
if (self.weapon == IT_EXTRA_WEAPON)
{
if (self.secondary_weapon == NIT_MEDIKIT)
return TRUE;
if (self.secondary_weapon == NIT_BIOWEAPON)
return TRUE;
}
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
// drop the weapon down
return FALSE;
};
/*====================
W_Reload
Is called when weapon has finished reloading
====================*/
void() W_Reload_shotgun =
{
self.owner.tfstate = self.owner.tfstate - (self.owner.tfstate & TFSTATE_RELOADING);
self.owner.weaponmodel = "progs/v_shot.mdl";
sprint(self.owner, "finished reloading\n");
remove(self);
};
void() W_Reload_super_shotgun =
{
self.owner.tfstate = self.owner.tfstate - (self.owner.tfstate & TFSTATE_RELOADING);
self.owner.weaponmodel = "progs/v_shot2.mdl";
sprint(self.owner, "finished reloading\n");
remove(self);
};
void() W_Reload_grenade_launcher =
{
self.owner.tfstate = self.owner.tfstate - (self.owner.tfstate & TFSTATE_RELOADING);
self.owner.weaponmodel = "progs/v_rock.mdl";
sprint(self.owner, "finished reloading\n");
remove(self);
};
void() W_Reload_rocket_launcher =
{
self.owner.tfstate = self.owner.tfstate - (self.owner.tfstate & TFSTATE_RELOADING);
self.owner.weaponmodel = "progs/v_rock2.mdl";
sprint(self.owner, "finished reloading\n");
remove(self);
};
void() W_Cool_assault_cannon =
{
self.owner.heat = 0;
if (self.owner.weapon == IT_EXTRA_WEAPON && self.owner.secondary_weapon == NIT_ASSAULT_CANNON)
self.owner.weaponmodel = "progs/v_nail2.mdl";
sprint(self.owner, "Assault cannon cooled.\n");
remove(self);
};
/*
============
W_Attack
An attack impulse can be triggered now
============
*/
void() player_axe1;
void() player_axeb1;
void() player_axec1;
void() player_axed1;
void() player_shot1;
void() player_nail1;
void() player_light1;
void() player_rocket1;
void() player_autorifle1;
void() player_assaultcannon1;
void() player_medikit1;
void() player_medikitb1;
void() player_medikitc1;
void() player_medikitd1;
void() player_bioweapon1;
void() player_bioweaponb1;
void() player_bioweaponc1;
void() player_bioweapond1;
void() W_Attack =
{
local float r;
local entity tWeapon;
if (!W_CheckNoAmmo ())
return;
if (self.tfstate & TFSTATE_RELOADING)
return;
makevectors (self.v_angle); // calculate forward angle for velocity
self.show_hostile = time + 1; // wake monsters up
if (self.weapon == IT_AXE)
{
sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
r = random();
if (r < 0.25)
player_axe1 ();
else if (r<0.5)
player_axeb1 ();
else if (r<0.75)
player_axec1 ();
else
player_axed1 ();
self.attack_finished = time + 0.5;
}
else if (self.weapon == IT_SHOTGUN)
{
player_shot1 ();
W_FireShotgun ();
if (self.reload_shotgun >= RE_SHOTGUN)
{
self.attack_finished = time + 0.4;
self.reload_shotgun = 0;
sprint(self, "reloading...\n");
self.tfstate = (self.tfstate | TFSTATE_RELOADING);
tWeapon = spawn();
tWeapon.owner = self;
tWeapon.classname = "timer";
tWeapon.nextthink = time + RE_SHOTGUN_TIME;
tWeapon.think = W_Reload_shotgun;
self.weaponmodel = "";
self.weaponframe = 0;
}
else
{
self.attack_finished = time + 0.5;
self.reload_shotgun = self.reload_shotgun + 1;
}
}
else if (self.weapon == IT_SUPER_SHOTGUN)
{
player_shot1 ();
W_FireSuperShotgun ();
if (self.reload_super_shotgun >= RE_SUPER_SHOTGUN)
{
self.attack_finished = time + 0.7;
self.reload_super_shotgun = 0;
sprint(self, "reloading...\n");
self.tfstate = (self.tfstate | TFSTATE_RELOADING);
tWeapon = spawn();
tWeapon.owner = self;
tWeapon.classname = "timer";
tWeapon.nextthink = time + RE_SUPER_SHOTGUN_TIME;
tWeapon.think = W_Reload_super_shotgun;
self.weaponmodel = "";
self.weaponframe = 0;
}
else
{
self.attack_finished = time + 0.7;
self.reload_super_shotgun = self.reload_super_shotgun + 1;
}
}
else if (self.weapon == IT_NAILGUN)
{
player_nail1 ();
}
else if (self.weapon == IT_SUPER_NAILGUN)
{
player_nail1 ();
}
else if (self.weapon == IT_GRENADE_LAUNCHER)
{
player_rocket1();
W_FireGrenade();
if (self.reload_grenade_launcher >= RE_GRENADE_LAUNCHER)
{
self.attack_finished = time + 0.6;
self.reload_grenade_launcher = 0;
sprint(self, "reloading...\n");
self.tfstate = (self.tfstate | TFSTATE_RELOADING);
tWeapon = spawn();
tWeapon.owner = self;
tWeapon.classname = "timer";
tWeapon.nextthink = time + RE_GRENADE_LAUNCHER_TIME;
tWeapon.think = W_Reload_grenade_launcher;
self.weaponmodel = "";
self.weaponframe = 0;
}
else
{
self.attack_finished = time + 0.6;
self.reload_grenade_launcher = self.reload_grenade_launcher + 1;
}
}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{
player_rocket1();
W_FireRocket();
if (self.reload_rocket_launcher >= RE_ROCKET_LAUNCHER)
{
self.attack_finished = time + 0.8;
self.reload_rocket_launcher = 0;
sprint(self, "reloading...\n");
self.tfstate = (self.tfstate | TFSTATE_RELOADING);
tWeapon = spawn();
tWeapon.owner = self;
tWeapon.classname = "timer";
tWeapon.nextthink = time + RE_ROCKET_LAUNCHER_TIME;
tWeapon.think = W_Reload_rocket_launcher;
self.weaponmodel = "";
self.weaponframe = 0;
}
else
{
self.attack_finished = time + 0.8;
self.reload_rocket_launcher = self.reload_rocket_launcher + 1;
}
}
else if (self.weapon == IT_LIGHTNING)
{
player_light1();
self.attack_finished = time + 0.1;
sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
}
else if (self.weapon == IT_EXTRA_WEAPON)
{
if (self.secondary_weapon == NIT_SNIPER_RIFLE)
{
if (vlen(self.velocity) > NIT_SNIPER_RIFLE_MAX_MOVE)
return;
// player_sniper1 (); (TBD?)
player_shot1();
W_FireSniperRifle();
self.attack_finished = time + 3.0;
}
else if (self.secondary_weapon == NIT_AUTO_RIFLE)
{
// player_sniper1 (); (TBD?)
player_autorifle1();
W_FireAutoRifle();
self.attack_finished = time + 0.1;
}
else if (self.secondary_weapon == NIT_ASSAULT_CANNON)
{
// TBD: Do the 1 second "warm up cannon" noise, and
// then let them fire.
// Need 10 cells to power up the Assault Cannon
if (self.heat > 0)
{
sprint(self, "Assault cannon is still cooling...");
return;
}
if (self.ammo_cells < 10)
sprint(self, "Insufficient cells to power up the Assault Cannon.\n");
else
{
self.ammo_cells = self.ammo_cells - 10;
// Can't move while firing the Assault Cannon :)
stuffcmd(self,"cl_backspeed 0\n");
stuffcmd(self,"cl_forwardspeed 0\n");
stuffcmd(self,"cl_sidespeed 0\n");
player_assaultcannon1();
}
}
else if (self.secondary_weapon == NIT_MEDIKIT)
{
sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
r = random();
if (r < 0.25)
player_medikit1 ();
else if (r<0.5)
player_medikitb1 ();
else if (r<0.75)
player_medikitc1 ();
else
player_medikitd1 ();
self.attack_finished = time + 0.5;
}
else if (self.secondary_weapon == NIT_BIOWEAPON)
{
sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
r = random();
if (r < 0.25)
player_bioweapon1 ();
else if (r<0.5)
player_bioweaponb1 ();
else if (r<0.75)
player_bioweaponc1 ();
else
player_bioweapond1 ();
self.attack_finished = time + 0.5;
}
}
};
/*
============
W_ChangeWeapon
============
*/
void() W_ChangeWeapon =
{
local float it, am, fl;
if (self.tfstate & TFSTATE_RELOADING)
return;
it = self.items;
am = 0;
if (self.impulse == 1)
{
// do they have the axe?
if (!(self.items & IT_AXE) && !(self.items & NIT_BIOWEAPON))
{
// if not, they must have either BioWeapon or Medikit
if (self.weapon == IT_EXTRA_WEAPON && self.secondary_weapon == NIT_BIOWEAPON)
{
self.secondary_weapon = NIT_MEDIKIT;
}
else
{
self.secondary_weapon = NIT_BIOWEAPON;
self.weapon = IT_EXTRA_WEAPON;
}
}
else
{
if (self.items & IT_AXE)
{
self.weapon = IT_AXE;
}
else
{
self.weapon = 0;
}
}
W_SetCurrentAmmo ();
return;
}
else if (self.impulse == 2)
{
fl = IT_SHOTGUN;
if (self.ammo_shells < 1)
am = 1;
}
else if (self.impulse == 3)
{
fl = IT_SUPER_SHOTGUN;
if (self.ammo_shells < 2)
am = 1;
}
else if (self.impulse == 4)
{
fl = IT_NAILGUN;
if (self.ammo_nails < 1)
am = 1;
}
else if (self.impulse == 5)
{
fl = IT_SUPER_NAILGUN;
if (self.ammo_nails < 2)
am = 1;
}
else if (self.impulse == 6)
{
fl = IT_GRENADE_LAUNCHER;
if (self.ammo_rockets < 1)
am = 1;
if (self.weaponmode == GL_PIPEBOMB)
self.weaponmode = GL_NORMAL;
else if (self.weaponmode == GL_NORMAL)
self.weaponmode = GL_PIPEBOMB;
}
else if (self.impulse == 7)
{
fl = IT_ROCKET_LAUNCHER;
if (self.ammo_rockets < 1)
am = 1;
}
else if (self.impulse == 8)
{
fl = IT_LIGHTNING;
if (self.ammo_cells < 1)
am = 1;
}
self.impulse = 0;
if (!(self.items & fl))
{ // don't have the weapon or the ammo
sprint (self, "no weapon.\n");
return;
}
if (am)
{ // don't have the ammo
sprint (self, "not enough ammo.\n");
return;
}
//
// set weapon, set ammo
//
self.weapon = fl;
self.secondary_weapon = 0;
W_SetCurrentAmmo ();
};
/*
============
CheatCommand
============
*/
void() CheatCommand =
{
if (deathmatch || coop)
return;
if (self.tfstate & TFSTATE_RELOADING)
return;
self.ammo_rockets = 100;
self.ammo_nails = 200;
self.ammo_shells = 100;
self.items = self.items |
IT_AXE |
IT_SHOTGUN |
IT_SUPER_SHOTGUN |
IT_NAILGUN |
IT_SUPER_NAILGUN |
IT_GRENADE_LAUNCHER |
IT_ROCKET_LAUNCHER |
IT_KEY1 | IT_KEY2;
self.ammo_cells = 200;
self.items = self.items | IT_LIGHTNING;
self.impulse = 0;
self.items = self.items | IT_EXTRA_WEAPON;
self.weapon = IT_EXTRA_WEAPON;
self.secondary_items = self.secondary_items | NIT_SNIPER_RIFLE | NIT_AUTO_RIFLE | NIT_ASSAULT_CANNON;
self.secondary_weapon = NIT_SNIPER_RIFLE;
W_SetCurrentAmmo ();
};
/*
============
CycleWeaponCommand
Go to the next weapon with ammo
============
*/
void() CycleWeaponCommand =
{
local float it, am;
if (self.tfstate & TFSTATE_RELOADING)
return;
it = self.items;
self.impulse = 0;
while (1)
{
am = 0;
if (self.weapon == IT_AXE)
{
self.weapon = IT_SHOTGUN;
if (self.ammo_shells < 1)
am = 1;
}
else if (self.weapon == IT_SHOTGUN)
{
self.weapon = IT_SUPER_SHOTGUN;
if (self.ammo_shells < 2)
am = 1;
}
else if (self.weapon == IT_SUPER_SHOTGUN)
{
self.weapon = IT_NAILGUN;
if (self.ammo_nails < 1)
am = 1;
}
else if (self.weapon == IT_NAILGUN)
{
self.weapon = IT_SUPER_NAILGUN;
if (self.ammo_nails < 2)
am = 1;
}
else if (self.weapon == IT_SUPER_NAILGUN)
{
self.weapon = IT_GRENADE_LAUNCHER;
self.weaponmode = GL_NORMAL;
if (self.ammo_rockets < 1)
am = 1;
}
else if (self.weapon == IT_GRENADE_LAUNCHER && self.weaponmode == GL_NORMAL)
{
self.weapon = IT_GRENADE_LAUNCHER;
self.weaponmode = GL_PIPEBOMB;
if (self.ammo_rockets < 1)
am = 1;
}
else if (self.weapon == IT_GRENADE_LAUNCHER && self.weaponmode == GL_PIPEBOMB)
{
self.weapon = IT_ROCKET_LAUNCHER;
if (self.ammo_rockets < 1)
am = 1;
}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{
self.weapon = IT_LIGHTNING;
if (self.ammo_cells < 1)
am = 1;
}
else if (self.weapon == IT_LIGHTNING)
{
self.weapon = IT_EXTRA_WEAPON;
self.secondary_weapon = NIT_SNIPER_RIFLE;
if (self.ammo_shells < 1)
am = 1;
}
else if (self.weapon == IT_EXTRA_WEAPON)
{
if (self.secondary_weapon == NIT_SNIPER_RIFLE)
{
self.secondary_weapon = NIT_AUTO_RIFLE;
if (self.ammo_shells < 1)
am = 1;
}
else if (self.secondary_weapon == NIT_AUTO_RIFLE)
{
self.secondary_weapon = NIT_ASSAULT_CANNON;
if (self.ammo_cells < 10)
am = 1;
if (self.ammo_shells < 1)
am = 1;
if (self.heat > 0)
am = 1;
}
else if (self.secondary_weapon == NIT_ASSAULT_CANNON)
{
self.secondary_weapon = NIT_BIOWEAPON;
}
else if (self.secondary_weapon == NIT_BIOWEAPON)
{
self.secondary_weapon = NIT_MEDIKIT;
}
else if (self.secondary_weapon == NIT_MEDIKIT)
{
self.weapon = IT_AXE;
self.secondary_weapon = 0;
}
}
// check if player actually has the weapon
// if not, loop again
if ((self.items & self.weapon) && (am == 0))
{
if (self.weapon == IT_EXTRA_WEAPON)
{
if (self.secondary_items & self.secondary_weapon)
{
W_SetCurrentAmmo ();
return;
}
}
else
{
W_SetCurrentAmmo ();
return;
}
}
}
};
/*
============
ServerflagsCommand
Just for development
============
*/
void() ServerflagsCommand =
{
serverflags = serverflags * 2 + 1;
};
void() QuadCheat =
{
if (deathmatch || coop)
return;
self.super_time = 1;
self.super_damage_finished = time + 30;
self.items = self.items | IT_QUAD;
dprint ("quad cheat\n");
};
/*
============
ImpulseCommands
============
*/
void() ImpulseCommands =
{
/*=====================
These Impulse commands rely on the use of self.last_impulse. Since they use
self.impulse for their own purposes, they _must_ be placed before the other
self.impulse tests, and they _must_ set self.impulse = 0 when they're done.
=====================*/
// TeamFortress Detpack
if (self.last_impulse == TF_DETPACK && self.impulse)
TeamFortress_SetDetpack(self.impulse);
// TeamFortress Scan
if (self.last_impulse == TF_SCAN && self.impulse)
TeamFortress_Scan(self.impulse);
// TeamFortress Help
if (self.last_impulse == TF_HELP && self.impulse)
TeamFortress_Help(self.impulse);
// TeamFortress Toggleable Game Setting
if (self.last_impulse == TF_TOGGLE && self.impulse)
TeamFortress_Toggle(self.impulse);
// TeamFortress Multiskin Set Skin
if (self.last_impulse == TF_MULTISKIN && self.impulse)
TeamFortress_Multiskin(self.impulse);
// TeamFortress Team Functions
if (self.last_impulse == TF_TEAM && self.impulse)
TeamFortress_Team(self.impulse);
/*=====================
The rest of these Impulse Commands don't use self.last_impulse. They _must_
be placed _after_ the Impulse Commands that do require self.last_impulse
=====================*/
// The sniper rifle replaces the normal shotgun
if (self.impulse == 2 && (self.secondary_items & NIT_SNIPER_RIFLE))
TeamFortress_SniperWeapon();
// The Assault cannon replaces the rocket launcher
if (self.impulse == 7 && (self.secondary_items & NIT_ASSAULT_CANNON))
TeamFortress_AssaultWeapon();
if (self.impulse >= 1 && self.impulse <= 8)
W_ChangeWeapon ();
if (self.impulse == 10)
CycleWeaponCommand ();
if (self.impulse == 11)
ServerflagsCommand ();
// TeamFortress Inventory
if (self.impulse == TF_INVENTORY)
TeamFortress_Inventory();
// TeamFortress Show Toggleflag State
if (self.impulse == TF_SHOWTF)
TeamFortress_ShowTF();
// TeamFortress Multiskin
if ((self.impulse == TF_SKIN_NEXT) && (toggleflags & TFLAG_SKIN))
Multiskin_NextSkin();
if ((self.impulse == TF_SKIN_PREV) && (toggleflags & TFLAG_SKIN))
Multiskin_PrevSkin();
// TeamFortress Prime Grenade Type 1
if (self.impulse == TF_GRENADE_1)
TeamFortress_PrimeGrenade();
// TeamFortress Prime Grenade Type 2
if (self.impulse == TF_GRENADE_2)
TeamFortress_PrimeGrenade();
// TeamFortress Throw Grenade
if (self.impulse == TF_GRENADE_T)
TeamFortress_ThrowGrenade();
// TeamFortress Detonate Pipebmombs
if (self.impulse == TF_PB_DETONATE)
TeamFortress_DetonatePipebombs();
// TeamFortress Change PlayerClass
if (self.impulse >= TF_CHANGEPC && self.impulse < TF_CHANGEPC + PC_LASTCLASS )
TeamFortress_ChangeClass();
// TeamFortress Pre-Impulse Commands
if (self.impulse == TF_DETPACK)
self.last_impulse = self.impulse;
if (self.impulse == TF_SCAN)
self.last_impulse = self.impulse;
if (self.impulse == TF_HELP)
{
// If it's not a multiplayer game, point out the pre-impulse limitations
if (coop || deathmatch)
self.last_impulse = self.impulse;
else
{
sprint(self, "N.B. You are playing a single-player game. Some ");
sprint(self, "aliases, such as the help aliases, do not work in ");
sprint(self, "single-player unless you bind them to a key.\n");
sprint(self, "We suggest you start a multiplayer cooperative game ");
sprint(self, "and play on your own.\n");
sprint(self, "For more info on this, read the readme.txt\n");
}
}
if (self.impulse == TF_TOGGLE)
self.last_impulse = self.impulse;
if (self.impulse == TF_MULTISKIN)
self.last_impulse = self.impulse;
if (self.impulse == TF_TEAM)
self.last_impulse = self.impulse;
self.impulse = 0;
};
/*
============
W_WeaponFrame
Called every frame so impulse events can be handled as well as possible
============
*/
void() W_WeaponFrame =
{
if (time < self.attack_finished)
return;
// Stop calling this function so much
if (self.impulse == TF_ALIAS_CHECK)
return;
if (self.impulse != 0)
ImpulseCommands ();
// check for attack
if (self.button0)
{
// check for undefined player changing camera points
if (self.playerclass == PC_UNDEFINED)
{
// stop player from continuously cycling through all the points too fast
if (self.weaponmode == 0)
{
TF_MovePlayer();
self.weaponmode = 1;
}
return;
}
if (self.weapon != IT_EXTRA_WEAPON && self.secondary_weapon != NIT_ASSAULT_CANNON)
{
SuperDamageSound ();
W_Attack ();
}
else
{
// Only fire the Assault Cannon if the player is on the ground
if (self.flags & FL_ONGROUND)
{
SuperDamageSound ();
W_Attack ();
}
}
}
else if (self.playerclass == PC_UNDEFINED)
{
self.weaponmode = 0;
}
};
/*
========
SuperDamageSound
Plays sound if needed
========
*/
void() SuperDamageSound =
{
if (self.super_damage_finished > time)
{
if (self.super_sound < time)
{
self.super_sound = time + 1;
sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
}
}
return;
};